package com.ruoyi.warn.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.domain.vo.UserInfoVo;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.user.domain.UserInfo;
import com.ruoyi.user.domain.vo.DrugUserVo;
import com.ruoyi.user.service.IUserInfoService;
import com.ruoyi.common.core.domain.bo.CustomQueryBo;
import com.ruoyi.warn.domain.vo.RyDetailVo;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * @author zhangxiaohao
 * @comment 自定义查询
 * @date 2023/5/7
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/customQuery")
public class CustomQueryController {
    private final IUserInfoService userInfoService;
    /*
     * 自定义条件查询
     */
    @PostMapping("/page")
    public R<Page<UserInfoVo>> page(@RequestBody CustomQueryBo param, PageQuery pageQuery) {
        Page<UserInfoVo> list = userInfoService.customQueryPage(param, pageQuery);
        return R.ok(list);
    }

    /**
     * 导出
     */
    @PostMapping("/export")
    public void export(HttpServletResponse response, @RequestBody CustomQueryBo param) {
        List<UserInfoVo> list = userInfoService.customQueryList(param);
        ExcelUtil.exportExcel(list, "戒毒人员", UserInfoVo.class, response);
    }
}
